import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入组件
// import Home from '../views/HomeTop.vue'
import User from '../views/UserTwo.vue'
import Main from '../views/MainTop.vue'
import Mall from '../views/Mall.vue'
import PegeOne from '../views/PegeOne.vue'
import PegeTwo from '../views/PegeTwo.vue'
import LoginTop from '@/views/LoginTop.vue'

Vue.use(VueRouter)

// 1.创建路由组件
// 2.将路由与组件进行映射
// 

const routes = [
  // 主路由
  {
    path:'/',
    component: Main,
    name: 'Main',

    // 重定向跳转
    redirect:'/home',
    //子路由
    children:[
      {
        // 这个名称是显示在网站输入框中的
        path: 'home',
        name: 'home',
        //下面显示的是文件引入的名称
        component: () => import('../views/HomeTop.vue')
      },
      {
        // 这个名称是显示在网站输入框中的
        path: 'user',
        name: 'user',
        //下面显示的是文件引入的名称
        component: User
      },
      {
        path:'mall',
        name: 'mall',
        component: Mall
      },
      {
        path:'page1',
        name: 'page1',
        component: PegeOne
      },
      {
        path:'page2',
        name: 'page2',
        component: PegeTwo
      }
    ]
  },
  {
    path:'/LoginTop',
    name: 'LoginTop',
    component: LoginTop
  }
]

// 创建routes实例，在传回配置
const router = new VueRouter({
  routes //缩写相当于routes: routes
})

//给routes实例进行暴露
export default router
